import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App'
import { HashRouter, Switch, Route, Redirect } from 'react-router-dom';
import { mainRoutes } from './routes';
import { Provider } from 'react-redux';
import store from './store';

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
  <React.StrictMode>
    <Provider store={store}>
      <HashRouter>
        <Switch>
          <Route path='/admin' render={routeProps => <App {...routeProps} />} />
          {
            mainRoutes.map(route => {
              return <Route key={route.path} {...route} />
            })
          }
          <Redirect to='/admin' from="/" />
          <Redirect to='/404' />
        </Switch>
      </HashRouter>
    </Provider>
  </React.StrictMode>
);

